module kernel.core.kmain;
import kernel.core.kprintf;
import kernel.mem.manager;
import kernel.arch.x86.gdt;

//magic = unique ID from the bootloader
//addr = address to a structure given by the bootloader
extern(C) void main(uint magic, uint addr) {
	kprintfln!("{!cls}Welcome to {} v{}.{}.{}!")("HIMTOS",0,0,1);
	kprintfln!("Booting:")();

	//First thing's first... lets initialize some or are stuff..
	kprintf!("\t{!fg:Green}--> {!fg:White}Initializing GDT")();
	if (GDT.init()) {
		printOK();
	} else {
		printError();
		halt();
	}

	kprintf!("\t{!fg:Green}--> {!fg:White}Initializing Memory Manager")();
	if (MemoryManager.init(addr)) {
		printOK();
	} else {
		printError();
		halt();
	}

	for (;;) {
		
	}
}

void printOK() {
	kprintfln!("{!pos:73,-1}{!fg:Blue}[ {!fg:Green}OK {!fg:Blue}]")();
}

void printError() {
	kprintfln!("{!pos:69,-1}{!fg:Blue}[ {!fg:Red}FAILED {!fg:Blue}]")();
}

void halt() {
	for(;;) {}
}
